#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
//priority_queue<int,vector<int> >
//next_permutation

struct car
{
    int d, v, a;
};

int jv(int s, int v0, int a)
{
    return 2*a*s+v0*v0;
}

int ans2;

void dfs(int x, map<int,int>vis, vector<int>g[], vector<int>s, set<int>sy)
{
    for (int i = 0; i < s.size(); i++)
    {
        int u = s[i];
        if (!vis[u]) continue;
        vis[u] = 0;
        set<int>sy1 = sy;
        for (int i = 0; i < g[u].size(); i++) if (sy1.count(g[u][i])) sy1.erase(g[u][i]);
        if (!sy1.size())
        {
            ans2 = min(ans2, x);
            return;
        }
        dfs(x+1,vis,g,s,sy1);
        vis[u] = 1;
    }
    return;
}

void solve()
{
    int n, m, l, v;
    map<int,int>vis;
    map<int,int>vis1;
    vector<int>ocp, g[100010];
    cin >> n >> m >> l >> v;
    v = v*v;
    vector<int>p(m+1);
    vector<car>a(n+1);
    set<int>sy;
    int ans = 0, cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].d >> a[i].v >> a[i].a;
    }
    for (int i = 1; i <= m; i++) cin >> p[i];
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (p[j] < a[i].d) continue;
            if (jv(p[j]-a[i].d,a[i].v,a[i].a) > v)
            {
                g[j].pb(i);
                ocp.pb(j);
                vis1[j] = 1;
                if (!vis[i])
                {
                    ans++;
                    sy.insert(i);
                    vis[i] = 1;
                }
            }
        }
    }
    sort(ocp.begin(),ocp.end());
    unique(ocp.begin(),ocp.end());
    cout << ans << " ";
    ans2 = INT_MAX;
    dfs(1,vis1,g,ocp,sy);
    cout << m-vis1.size()+ans2 << endl;
}

signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
